<form action="/main/welcome" method="post">
  <div style="width:100%; text-align:left;">
    ค้นหารายวิชา : <input type="text" name="name" value="<%=@name%>"/> <input type="submit"/>
  </div>
</form>
<br/>
<%
  courses = nil
  if @name.empty?
    courses = Course.find(:all)
  else
    courses = Course.find(:all, :conditions=>["name LIKE ? OR description LIKE ?", "%#{@name}%", "%#{@name}%"])
  end
%>
<%courses.each do |course|%>
<table width="680px">
  <tr>
    <td>
      <%begin%>
        <%= link_to image_tag('/files/'+course.image), :controller=>'course', :action=>:content, :id=>course.id%>
      <%rescue%>
        <%= link_to "Details", :controller=>'course', :action=>:content, :id=>course.id%>
      <%end%>
    </td>
    <td width="400px">
      <div class="course_name"><a href="/course/content/<%=course.id%>" style="color:white;"><%=course.name%></a></div>
      <br/>
      <div class="description"><%=course.description%></div>
    </td>
    <td valign="middle" style="vertical-align:middle;" width="80px">
       <input type="button" value="Comments" onclick="<%=remote_function(:update=>"course_area_#{course.id}", :url=>{:action=>:show_comments, :id=>course.id})%>"/> 
    </td>
  </tr>
  <tr>
    <td colspan="3" align="center">
      <span id="course_area_<%=course.id%>"></span>
    </td>
  </tr>
</table>
<%end%>